//
//  ReflectionView.m
//  Test
//
//  Created by mac on 2017/8/24.
//  Copyright © 2017年 mac. All rights reserved.
//

#import "ReflectionView.h"

@implementation ReflectionView

-(instancetype)initWithFrame:(CGRect)frame{
    
    if (self = [super initWithFrame:frame]) {
        [self setUp];
    }
    
    return self;
}

-(void)awakeFromNib{
    
    [super awakeFromNib];
         [self setUp];
}
+(Class)layerClass{
    
    return [CAReplicatorLayer class];
}

-(void)setUp{
    
    CAReplicatorLayer *layer = (CAReplicatorLayer *)self.layer;
    
    layer.instanceCount = 2;
    //做3d转换
    CGFloat vertificationOffect = self.bounds.size.height;
    CATransform3D transform = CATransform3DIdentity;
    transform = CATransform3DTranslate(transform, 0, vertificationOffect+2, 0);
//    transform = CATransform3DScale(transform, 1, -1, 0);
    transform = CATransform3DRotate(transform, M_PI, 0, 0, -1);
    layer.transform = transform;
    layer.instanceAlphaOffset = -0.6;
    layer.contentsScale = [UIScreen mainScreen].scale;
    UIImage *img = [UIImage imageNamed:@"Image-1"];
    layer.contents = (__bridge id _Nullable)(img.CGImage);
    

}
@end
